CAMEL-24505: camel-micrometer-starter - bound the uri metric tag - #1933
Merged
Conversation
The uri low cardinality tag of the http.server.requests metrics was set to request.getServletPath() + getPathInfo() whenever the request did not resolve to a Camel HTTP consumer. Micrometer registers a meter per distinct tag value and keeps it for the lifetime of the process, so the meters followed the number of distinct paths that clients requested, instead of the number of routes, and the memory they use grows with the traffic a deployment receives. Requests that do not resolve to a Camel consumer now keep the uri computed by Spring's own DefaultServerRequestObservationConvention: the mapped pattern for a Spring MVC endpoint, and a constant (UNKNOWN, NOT_FOUND, REDIRECTION) otherwise. That is also what the uriTagEnabled javadoc already documents, that an unresolved request "will be marked as UNKNOWN". Requests that do resolve to a Camel consumer are unchanged and keep the static consumer path. With uriTagDynamic the requested path is still used, as that is the documented purpose of the option, but only for requests that resolve to a Camel consumer, and the value is capped and stripped of control characters. The auto-configuration was also conditional on camel.metrics.uriTagEnabled, a spelling that Spring Boot cannot resolve from a relaxed binding source, so the camel.metrics.uri-tag-enabled property listed in the starter documentation never enabled the uri tag. The condition now uses the kebab-case name, and both spellings work. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
oscerd
approved these changes
Sep 2, 2026
Croway
force-pushed
the
CAMEL-24505-micrometer-uri-tag
branch
from
September 2, 2026 13:12
576b372 to
f01b92a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes CAMEL-24505.
What
MicrometerTagsAutoConfigurationcontributes theurilow cardinality tag of thehttp.server.requestsmetrics. When the request did not resolve to a Camel HTTP consumer — any 404, any request served by something
other than the Camel servlet — the tag was
request.getServletPath() + getPathInfo()verbatim.Micrometer registers one meter per distinct tag value and keeps it for the lifetime of the process, so the
number of meters followed the number of distinct paths clients had requested rather than the number of routes,
and the memory used by the registry grew with the traffic a deployment received.
CamelMetricsConfiguration'sown javadoc for
uriTagEnabledalready states that an unresolved request "will be marked as UNKNOWN", so thecode contradicted the documented behaviour.
Changes
urikey value. The value computedby Spring's own
DefaultServerRequestObservationConventionstands instead: the mapped pattern for a SpringMVC endpoint, and a constant (
UNKNOWN,NOT_FOUND,REDIRECTION) otherwise. This keeps the tag boundedand, unlike hard-coding
UNKNOWNhere, does not throw away the pattern of the Spring MVC and actuatorendpoints of the same application.
/users/{id}.camel.metrics.uri-tag-dynamic = truestill tags with the requested path (/camel/users/123), which is thedocumented purpose of the option, but only for requests that resolve to a Camel consumer. The consumer is now
resolved in that mode too, and the value is capped at 200 characters and stripped of control characters so a
single tag value stays bounded in size.
camel.metrics.uriTagEnabled. Spring Boot cannot resolve thatcamelCase name from a relaxed binding source, so
camel.metrics.uri-tag-enabled = true— the name listed inthe starter documentation — never enabled the uri tag at all. The condition now uses the kebab-case name;
both spellings work, since the kebab-case name does resolve through relaxed binding.
Behaviour change
camel.metrics.uri-tag-enabled = true(kebab-case) now get the Camel uri tagwhere before the auto-configuration silently did not apply.
uritag of requests that are not served by a Camel consumer is the Spring value instead of the rawrequested path. Dashboards and alerts matching on those raw paths need to use the Spring value.
An upgrade guide entry for the
camel-spring-bootsection of the Camel 4.23 upgrade guide will be proposedseparately in
apache/camel.Tests
New tests in
components-starter/camel-micrometer-starter/src/test(the starter had none), booting the starterwith
camel-servlet-starteron a random port and asserting on thehttp.server.requestsmeters:MicrometerUriTagTest— 10 requests to 10 distinct unmatched paths produce a single meter, and no metercarries a requested path; a matched
servlet:/users/{id}route yieldsuri=/users/{id}.MicrometerUriTagDynamicTest— same cardinality assertion withuriTagDynamic = true, plus the requestedpath being used for matched requests and a 300 character path being capped. This class configures the
properties in the legacy camelCase spelling, so both spellings stay covered.
mvn install -pl components-starter/camel-micrometer-starter→Tests run: 5, Failures: 0, Errors: 0.Both cardinality assertions fail against the previous logic (10 meters for 10 unmatched paths), verified by
running the new tests against it.
The regenerated
src/main/docs/micrometer.jsonanddocs/spring-boot/.../starters/micrometer.adocareincluded.
Claude Code (Opus 5) on behalf of Federico Mariani